import { faker } from '@faker-js/faker';
import {Album} from '../album/albums';
import {generateAlbum} from '../album/albums';
// 定义 Album 接口
export interface Song {
    id: number;
    name: string;
    song?: string,
    picUrl: string;
    bio?: string;
    key?: number,
    index?: number,
    artist: string,
    album: Album,
    duration: number,
    songUrl: string,
    //https://er-sycdn.kuwo.cn/0b1da226bf96bd166d04c5c953e4a3b9/67876cf7/resource/30106/trackmedia/M800002T9amM049EZl.mp3
}

// 生成单个 Album 的模拟数据
async function generateSong(): Promise<Song> {
    return {
        id: faker.number.int({ min: 1, max: 10000 }),
        name: faker.music.songName().slice(0, 10),
        picUrl: faker.image.url(),
        bio: faker.lorem.paragraph(),
        key: faker.number.int({ min: 1, max: 10000 }),
        index: faker.number.int({ min: 1, max: 10000 }),
        artist: faker.music.artist(),  
        album: {
            id: faker.number.int({ min: 1, max: 10000 }),
            name: faker.music.songName().slice(0, 10),
            picUrl: faker.image.url(),
            bio: faker.lorem.paragraph(),
            songs: []  ,// 这里先设置为空数组,
            artist: {
                id: faker.string.uuid(),
                name: faker.music.artist(),
                avatar: faker.image.url(),
                followings: faker.number.int({ min: 1, max: 10000 }),
                followers: faker.number.int({ min: 1, max: 10000 }),
                likedSongs: [],
                createTime: faker.date.recent(),
                sex: faker.person.sex(),
                description: faker.lorem.paragraph(),
                songs: [],
                albums: [],
                category: [],
            },
        },
        duration: faker.number.int({ min: 1, max: 10000 }),
        songUrl: "https://downsc.chinaz.net/Files/DownLoad/sound1/202205/y860.mp3"
    };
}

// 生成多个 Song 的模拟数据，数量随机
export async function generateSongs(maxCount: number = 50): Promise<Song[]> {
    const randomCount = faker.number.int({ min: 1, max: maxCount });
    const songs: Song[] = [];
    
    for (let i = 0; i < randomCount; i++) {
        songs.push(await generateSong());
    }
    
    return songs;
}

// 示例：生成最多 50 首歌的模拟数据
export const mockSongs = generateSongs();

// const data = [
//     {
//         id: '1',
//         key: '1',
//         index: '1',
//         song: '土坡上的狗尾巴草',
//         artist: '卢润泽',
//         album: '土坡上的狗尾巴草',
//         duration: '03:15',
//     },
//     {
//         id: '2',
//         key: '2',
//         index: '2',
//         song: '土坡上的狗尾巴草',
//         artist: '卢润泽',
//         album: '土坡上的狗尾巴草',
//         duration: '03:15',
//     },
//     // 更多数据...
// ];